package com.hzqy.web.ac.epg;


import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hzqy.commons.utils.ExcelUtil;
import com.hzqy.commons.utils.ExcelUtil.MyEntry;
import com.hzqy.service.epg.MovieAndSerialServiceBean;
import com.hzqy.service.system.SysVoProcessServiceBeen;
import com.hzqy.web.vo.activity.ActivityVoteUserVo;

@Controller
@RequestMapping("/")
public class MovieAndSerialAction {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	@Resource
	private MovieAndSerialServiceBean masService;
	@Resource
	private SysVoProcessServiceBeen voProcessServiceBean;
	
	
	/**
	 * 查询用户投票总数及排序
	 * @param acvote
	 * @return selectSisterVotenumExcel
	 */
	@RequestMapping(value="/mas/selectSisterVotenum")
	@ResponseBody
	public Object selectSisterVotenum(ActivityVoteUserVo acvote,int page, int rows) {
		Map<String,Object> map = new HashMap<String,Object>();
		map = masService.selectSisterVotenum(acvote,page,rows);
		return map;
	}
	
	@RequestMapping(value="/mas/selectSisterVotenumExcel")
	@ResponseBody
	public void billExcelList(ActivityVoteUserVo acvote,HttpServletResponse response)throws IOException {
		Map<String,Object> ExcelListMap = new HashMap<String, Object>();
		
		ExcelListMap = masService.selectSisterVotenumExcel(acvote);
		List<ActivityVoteUserVo> list = (List<ActivityVoteUserVo>)ExcelListMap.get("rows");
		//voProcessServiceBean.voProcess(list);
		List<MyEntry<String, String>> excelCpHeader=new ArrayList<MyEntry<String, String>>();
		excelCpHeader.add(new MyEntry<String,String>("rownum","排名"));
		excelCpHeader.add(new MyEntry<String,String>("f_avu_serverid","业务账号"));
		excelCpHeader.add(new MyEntry<String,String>("phone","电话号码"));
		excelCpHeader.add(new MyEntry<String,String>("sumvote","总票数"));
		excelCpHeader.add(new MyEntry<String,String>("maxdate","投票时间"));
		boolean flag=ExcelUtil.generateExcel(list, excelCpHeader, response);
	}
}
